//
//  JBHomeTableViewController.swift
//  sinaBlog
//
//  Created by jobo on 15/10/27.
//  Copyright © 2015年 jobo. All rights reserved.
//

import UIKit

class JBHomeTableViewController: JBBaseTableViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        //判断是否已经登录
        if JBUserAccount.loadAccount() == nil
        {
            print("没有登录")
            return
        }
        
        print("---------加载微博数据")
        
        //设置导航栏左右按钮
        setNavigationBar()
        
        //获取微博数据
        JBStatus.loadStatus { (statuses, error) -> () in
            print(statuses)
            print(error)
        }
    
    
    }

    
    //设置导航栏按钮
    func setNavigationBar()
    {
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: letBtn)
        
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(customView: rightBtn)
        
        //设置首页title
        let name = JBUserAccount.loadAccount()?.name ?? "没有登录"
        
        let button = UIButton()
        
        button.setTitle(name , forState: UIControlState.Normal)
        
        button.setImage(UIImage(named: "navigationbar_arrow_down"), forState: UIControlState.Normal)
        
        button.setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal)
        
        button.sizeToFit()
        
        self.navigationItem.titleView = button
       
    
    }
    //懒加载
    lazy var letBtn : UIButton =
    {
        var btn = UIButton()
        
        btn.setImage(UIImage(named: "navigationbar_friendsearch"), forState: UIControlState.Normal)
        
        btn.setImage(UIImage(named: "navigationbar_friendsearch_highlighted"), forState: UIControlState.Highlighted)
        
        btn.sizeToFit()
        
        return btn
    
    }()
    
    lazy var rightBtn : UIButton =
    {
    
        var btn = UIButton()
        
        btn.setImage(UIImage(named: "navigationbar_pop"), forState: UIControlState.Normal)
        
        btn.setImage(UIImage(named: "navigationbar_pop_highlighted"), forState: UIControlState.Highlighted)
        
        btn.sizeToFit()
        
        return btn

        
    }()
    
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    // MARK: - Table view data source

    override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        // #warning Incomplete implementation, return the number of sections
        return 0
    }

    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        // #warning Incomplete implementation, return the number of rows
        return 0
    }

    
}
